package com.yuexunit.account.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.yuexunit.account.action.v2.model.VerifyCodeType;
import com.yuexunit.persist.annotation.Cacheable;
import com.yuexunit.util.DateUtil;
import com.yuexunit.util.StringUtil;

@Entity
@Table(name="AC_VERIFY_CODE")
@Cacheable
public class VerifyCodeEntity {
	@Id
	@GeneratedValue
	@Column(name="VERIFY_CODE_ID")
	private Long verifyCodeId;

	@Column(name="ACCOUNT_NAME")
	private String accountName;

	@Column(name="VERIFY_TYPE")
	@Enumerated
	private VerifyCodeType type;

	@Column(name="VERIFY_CODE")
	private String verifyCode;
	
	@Column(name="EXPIRE_DT")
	private Date expireDate;
	
	@Column(name="CREATE_DT")
	private Date createDate;

	public VerifyCodeEntity() {
	}
	
	public VerifyCodeEntity(String accountName, VerifyCodeType type) {
		this.accountName = accountName;
		this.type = type;
		this.verifyCode = StringUtil.randomCode6Digits();
		this.expireDate = DateUtil.after1Hour();
		this.createDate = DateUtil.now();
	}
	

	public Long getVerifyCodeId() {
		return verifyCodeId;
	}

	public void setVerifyCodeId(Long verifyCodeId) {
		this.verifyCodeId = verifyCodeId;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	public VerifyCodeType getType() {
		return type;
	}

	public void setType(VerifyCodeType type) {
		this.type = type;
	}

	public String getVerifyCode() {
		return verifyCode;
	}

	public void setVerifyCode(String verifyCode) {
		this.verifyCode = verifyCode;
	}

	public Date getExpireDate() {
		return expireDate;
	}

	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
}
